# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-uuseg
_pkgname=uuseg
pkgver=14.0.0
pkgrel=0
pkgdesc="Unicode text segmentation for OCaml"
url="https://erratique.ch/software/uuseg"
# limited by riscv64: ocaml, ppc64le: ocaml-uucp
arch="all !riscv64 !ppc64le"
license="ISC"
depends="ocaml-runtime ocaml-uucp ocaml-uutf"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-uucp-dev ocaml-uutf-dev"
makedepends="
	$depends_dev
	ocaml
	ocamlbuild
	ocaml-compiler-libs
	ocaml-cmdliner-dev
	ocaml-findlib
	ocaml-topkg
	cmd:opam-installer
	"
options="!check"  # no tests provided
subpackages="$pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.bz2::https://erratique.ch/software/uuseg/releases/uuseg-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	ocaml pkg/pkg.ml build \
		--with-uutf true \
		--with-cmdliner true
}

package() {
	opam-installer -i \
		--prefix="$pkgdir"/usr \
		--libdir="$pkgdir/$_ocamldir" \
		--docdir="$builddir"/.omit \
		$_pkgname.install
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

tools() {
	pkgdesc="$pkgdesc (command line utilities)"
	depends=""

	amove usr/bin
}

sha512sums="
3f089baf95f010663a0c2f060b2911395d9b396f478efb10fd979815f527c9e61e0a70b3192f2e921f59287bfde0da6e25109d4a1825554e2e4a50c0535e97aa  ocaml-uuseg-14.0.0.tar.bz2
"
